home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 Extra / Chip_Extra_1999.iso / share / aktuell / mimarzip / m8vcs99.exe / MimarSinan ACE Wrapper (ACE) / ace12b / UNACESRC / UNIX / GCCMAKED next >
Encoding:
Text File  |  1998-07-03  |  2.2 KB  |  137 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # makedepend which uses 'gcc -MM'
  5. #
  6. # $XFree86: xc/config/util/gccmdep.cpp,v 3.3 1996/02/25 01:16:15 dawes Exp $
  7. #
  8. # Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl@nynexst.com>
  9. #
  10.  
  11. TMP=/tmp/mdep$$
  12. CC="gcc"
  13. RM="rm -f"
  14. LN="ln -s"
  15. MV="mv -f"
  16.  
  17. trap "$RM ${TMP}*; exit 1" 1 2 15
  18. trap "$RM ${TMP}*; exit 0" 1 2 13
  19.  
  20. files=
  21. makefile=
  22. endmarker=
  23. magic_string='# DO NOT DELETE'
  24. append=n
  25. args=
  26. asmfiles=
  27.  
  28. while [ $# != 0 ]; do
  29.     if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
  30.     endmarker=
  31.     else
  32.     case "$1" in
  33.         -D*|-I*)
  34.         args="$args '$1'"
  35.         ;;
  36.         -g|-o)
  37.         ;;
  38.         *)
  39.         if [ "$endmarker"x = x ]; then
  40.             case $1 in
  41. # ignore these flags
  42.             -w|-o|-cc)
  43.                 shift
  44.                 ;;
  45.             -v)
  46.                 ;;
  47.             -s)
  48.                 magic_string="$2"
  49.                 shift
  50.                 ;;
  51.             -f-)
  52.                 makefile="-"
  53.                 ;;
  54.             -f)
  55.                 makefile="$2"
  56.                 shift
  57.                 ;;
  58.             --*)
  59.                 endmarker=`echo $1 | sed 's/^\-\-//'`
  60.                 if [ "$endmarker"x = x ]; then
  61.                 endmarker="--"
  62.                 fi
  63.                 ;;
  64.             -a)
  65.                 append=y
  66.                 ;;
  67.             -*)
  68.                 echo "Unknown option '$1' ignored" 1>&2
  69.                 ;;
  70.             *)
  71.                 files="$files $1"
  72.                 ;;
  73.             esac
  74.         fi
  75.         ;;
  76.     esac
  77.     fi
  78.     shift
  79. done
  80.  
  81. if [ x"$files" = x ]; then
  82. # Nothing to do
  83.     exit 0
  84. fi
  85.  
  86. case "$makefile" in
  87.     '')
  88.     if [ -r makefile ]; then
  89.         makefile=makefile
  90.     elif [ -r Makefile ]; then
  91.         makefile=Makefile
  92.     else
  93.         echo 'no makefile or Makefile found' 1>&2
  94.         exit 1
  95.     fi
  96.     ;;
  97. esac
  98.  
  99. if [ X"$makefile" != X- ]; then
  100.     if [ x"$append" = xn ]; then
  101.         sed -e "/^$magic_string/,\$d" < $makefile > $TMP
  102.         echo "$magic_string" >> $TMP
  103.     else
  104.         cp $makefile $TMP
  105.     fi
  106. fi
  107.  
  108. # need to link .s files to .S
  109. for i in $files; do
  110.     case $i in
  111.     *.s)
  112.         dir=`dirname $i`
  113.         base=`basename $i .s`
  114.         (cd $dir; $RM ${base}.S; $LN ${base}.s ${base}.S)
  115.         asmfiles="$asmfiles ${base}.S"
  116.         ;;
  117.     esac
  118. done
  119.  
  120. CMD="$CC -MM $args `echo $files | sed -e 's,\.s$,\.S,g' -e 's,\.s ,\.S ,g'` |     sed -e 's,\.S$,\.s,g' -e 's,\.S ,\.s ,g'"
  121.  
  122. if [ X"$makefile" != X- ]; then
  123.     CMD="$CMD >> $TMP"
  124. fi
  125. eval $CMD
  126. if [ X"$makefile" != X- ]; then
  127.     $RM ${makefile}.bak
  128.     $MV $makefile ${makefile}.bak
  129.     $MV $TMP $makefile
  130. fi
  131.  
  132. if [ x"$asmfiles" != x ]; then
  133.     $RM $asmfiles
  134. fi
  135. $RM ${TMP}*
  136. exit 0
  137.